package com.ljkj.blockpay.ui.adapter;


import android.util.Log;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ljkj.blockpay.R;
import com.ljkj.blockpay.model.HistoryDealModel;
import com.ljkj.blockpay.model.TimeModel;

import java.util.List;

public class HistoryAdapter extends BaseQuickAdapter<TimeModel, BaseViewHolder> {

    private SetAdpItemChickListener setAdpItemChickListener;

    public HistoryAdapter(int layoutResId, @Nullable List<TimeModel> data) {
        super(layoutResId, data);
    }

    public void setSetAdpItemChickListener(SetAdpItemChickListener setAdpItemChickListener) {
        this.setAdpItemChickListener = setAdpItemChickListener;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, TimeModel item) {
        helper.setText(R.id.tv_headtime,item.getYearDay());
      RecyclerView recyclerView =  helper.getView(R.id.recyclerView);
      recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        List<TimeModel.DataTimeModel> list = item.getList();
        HistoryListAdapter historyListAdapter = new HistoryListAdapter(R.layout.item_historylist,list);
      recyclerView.setAdapter(historyListAdapter);
      recyclerView.setVisibility(item.isSwitchBoolean()? View.VISIBLE:View.GONE);
      historyListAdapter.setOnItemClickListener((adapter, view, position) -> {
          if (setAdpItemChickListener != null){
             setAdpItemChickListener.listener(getItemPosition(item),position);
          }
      });
    }

  public interface SetAdpItemChickListener{
        void listener(int position,int itemPosition);
    }




}
